package yhq.webmagic;

import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.model.ConsolePageModelPipeline;
import us.codecraft.webmagic.model.OOSpider;
import us.codecraft.webmagic.model.annotation.ExtractBy;
import us.codecraft.webmagic.model.annotation.TargetUrl;

/**
 * Created by yanghongquan on 2018/8/31 11:45
 */

@TargetUrl("http://top.baidu.com/?fr=mhd_card/")
@ExtractBy(value = "//ul[@id=\"hot-list\"]/li",multi = true)
public class YhqTry2 {

    @ExtractBy("//span[@class=numtop]/text()")
    private String number;
//    @ExtractBy("//div[@class=book-mid-info]/h4/a/text()")
//    private String title;
//    @ExtractBy("//div[@class=book-mid-info]/p[@class=author]/a[@class=name]/text()")
//    private String author;
//
//    @ExtractBy("//div[@class=book-mid-info]/p[@class=author]/a[@class=go-sub-type]/text()")
//    private String type;
//    @ExtractBy("//div[@class=book-mid-info]/p[@class=author]/span/text()")
//    private String status;
//
//    @ExtractBy("//div[@class=book-mid-info]/p[@class=intro]/text()")
//    private String intro;
//    @ExtractBy("//div[@class=book-mid-info]/p[@class=update]/span/text()")
//    private String count;

    public static void main(String[] args) {
//        OOSpider.create(Site.me(), new ConsolePageModelPipeline(), Qidian.class).addUrl("http://a.qidian.com/").thread(4).run();
        OOSpider ooSpider = OOSpider.create(Site.me().setSleepTime(100), new ConsolePageModelPipeline(), YhqTry2.class);

        YhqTry2 baidu = ooSpider.get("http://top.baidu.com/?fr=mhd_card/");

        System.out.println(baidu);
    }

}
